#pragma once
//封装信号量
#include<iostream>
#include<semaphore.h>
#include<pthread.h>//线程
#include<unistd.h>
class Sem
{
    const unsigned int value=1;
    public:
    Sem(const unsigned int value){//5
        sem_init(&_sem,0,value);
    }
    ~Sem(){
        sem_destroy(&_sem);
    }
    void P()
    {
        int ret=sem_wait(&_sem);
        (void)ret;
    }
    void V()
    {
        int ret=sem_post(&_sem);
        (void)ret;
    }
    private:

    sem_t _sem;
};